package main.com.oaer.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import main.com.oaer.dao.UserDao;
import main.com.oaer.dao.UserRoleDao;
import main.com.oaer.model.PageList;
import main.com.oaer.model.User;
import main.com.oaer.service.UserService;

@Service
public class UserServiceImpl implements UserService {

	@Autowired
	UserDao userDao;
	
	@Autowired
	UserRoleDao userRoleDao;
	
	@Override
	public User load(Long id) {
		return userDao.load(id);
	}
	
	@Override
	public void add(User user) {
		userDao.add(user);
	}

	@Override
	public PageList findUsersByPage(Integer currentPage, Integer pageSize,User user){		
		return userDao.findUsersByPage(currentPage, pageSize, user);
	}

	@Override
	public void delete(User user) {
		userDao.delete(user);
		userRoleDao.deleteByUserId(user.getId());
	}

	@Override
	public User findUserByUsername(String username) {
		return userDao.findUserByUsername(username);
	}

}
